mergeIndex jl refs
let commitrefs = nub $ fullname:refs
ifM (handleTransitions jl localtransitions commitrefs)
- ( runAnnexHook postUpdateAnnexHook
+ ( runAnnexHook postUpdateAnnexHook annexPostUpdateCommand
, do
ff <- if dirty
then return False
setIndexSha ref = do
f <- fromRepo gitAnnexIndexStatus
writeLogFile f $ fromRef ref ++ "\n"
- runAnnexHook postUpdateAnnexHook
+ runAnnexHook postUpdateAnnexHook annexPostUpdateCommand
{- Stages the journal into the index, and runs an action that
- commits the index to the branch. Note that the action is run
{- Runs a hook. To avoid checking if the hook exists every time,
- the existing hooks are cached. -}
-runAnnexHook :: Git.Hook -> Annex ()
-runAnnexHook hook = do
+runAnnexHook :: Git.Hook -> (GitConfig -> Maybe String) -> Annex ()
+runAnnexHook hook commandcfg = do
m <- Annex.getState Annex.existinghooks
case M.lookup hook m of
- Just True -> run
- Just False -> noop
+ Just True -> runhook
+ Just False -> runcommandcfg
Nothing -> do
exists <- inRepo $ Git.hookExists hook
Annex.changeState $ \s -> s
{ Annex.existinghooks = M.insert hook exists m }
- when exists run
+ if exists
+ then runhook
+ else runcommandcfg
where
- run = unlessM (inRepo $ Git.runHook hook) $ do
+ runhook = unlessM (inRepo $ Git.runHook hook) $ do
h <- fromRepo $ Git.hookFile hook
- warning $ UnquotedString $ h ++ " failed"
+ commandfailed h
+ runcommandcfg = commandcfg <$> Annex.getGitConfig >>= \case
+ Just command ->
+ unlessM (liftIO $ boolSystem "sh" [Param "-c", Param command]) $
+ commandfailed command
+ Nothing -> noop
+ commandfailed c = warning $ UnquotedString $ c ++ " failed"
* git-remote-annex: Use enableremote rather than initremote.
* Windows: Fix permission denied error when dropping files that
have the readonly attribute set.
+ * Added git configs annex.post-update-command and annex.pre-commit-command
+ that correspond to the git-annex hook scripts post-update-annex and
+ pre-commit-annex.
-- Joey Hess <id@joeyh.name> Fri, 03 Jan 2025 14:30:38 -0400
-- files in the worktree won't be populated, so populate them here
Command.Smudge.updateSmudged (Restage False)
- runAnnexHook preCommitAnnexHook
+ runAnnexHook preCommitAnnexHook annexPreCommitCommand
-- committing changes to a view updates metadata
currentView >>= \case
, annexAlwaysCompact :: Bool
, annexCommitMessage :: Maybe String
, annexCommitMessageCommand :: Maybe String
+ , annexPreCommitCommand :: Maybe String
+ , annexPostUpdateCommand :: Maybe String
, annexMergeAnnexBranches :: Bool
, annexDelayAdd :: Maybe Int
, annexHttpHeaders :: [String]
, annexAlwaysCompact = getbool (annexConfig "alwayscompact") True
, annexCommitMessage = getmaybe (annexConfig "commitmessage")
, annexCommitMessageCommand = getmaybe (annexConfig "commitmessage-command")
+ , annexPreCommitCommand = getmaybe (annexConfig "pre-commit-command")
+ , annexPostUpdateCommand = getmaybe (annexConfig "post-update-command")
, annexMergeAnnexBranches = getbool (annexConfig "merge-annex-branches") True
, annexDelayAdd = getmayberead (annexConfig "delayadd")
, annexHttpHeaders = getlist (annexConfig "http-headers")
This command is run and its output is used as the commit message to the
git-annex branch.
+* `annex.post-update-command`
+
+ This command is run after git-annex updates the git-annex branch.
+
+ Alternatively, a hook script can be installed in
+ `.git/hooks/post-update-annex`
+
+ When publishing a git-annex repository by http, this can be used to run
+ `git update-server-info`
+
+* `annex.pre-commit-command`
+
+ This command is run whenever a commit is made to the HEAD branch of
+ the git repository, either by git commit, or by git-annex.
+
+ Alternatively, a hook script can be installed in
+ `.git/hooks/pre-commit-annex`
+
* `annex.alwayscompact`
By default, git-annex compacts data it records in the git-annex branch.
`~/.config/git-annex/autostart` is a list of git repositories
to start the git-annex assistant in.
-`.git/hooks/pre-commit-annex` in your git repository will be run whenever
-a commit is made to the HEAD branch, either by git commit, git-annex
-sync, or the git-annex assistant.
-
-`.git/hooks/post-update-annex` in your git repository will be run
-whenever the git-annex branch is updated. You can make this hook run
-`git update-server-info` when publishing a git-annex repository by http.
-
# SEE ALSO
More git-annex documentation is available on its web site,